package com.yic.module.device.dal.mysql.inspectionPlanDevice;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.device.dal.dataobject.inspectionPlanDevice.InspectionPlanDeviceDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.device.controller.admin.inspectionPlanDevice.vo.*;

/**
 * 巡检计划与设备关联 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface InspectionPlanDeviceMapper extends BaseMapperX<InspectionPlanDeviceDO> {

    default PageResult<InspectionPlanDeviceDO> selectPage(InspectionPlanDevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDeviceDO>()
                .eqIfPresent(InspectionPlanDeviceDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(InspectionPlanDeviceDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(InspectionPlanDeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionPlanDeviceDO::getId));
    }

    default List<InspectionPlanDeviceDO> selectList(InspectionPlanDeviceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InspectionPlanDeviceDO>()
                .eqIfPresent(InspectionPlanDeviceDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(InspectionPlanDeviceDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(InspectionPlanDeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionPlanDeviceDO::getId));
    }

    default int deleteByPlanId(Long planId){
        return delete(new LambdaQueryWrapperX<InspectionPlanDeviceDO>()
                .eq(InspectionPlanDeviceDO::getPlanId,planId));
    }

    default List<InspectionPlanDeviceDO> selectListByPlanId(Long planId){
        return selectList(new LambdaQueryWrapperX<InspectionPlanDeviceDO>()
                .eq(InspectionPlanDeviceDO::getPlanId,planId)
                .orderByDesc(InspectionPlanDeviceDO::getId));
    }

    default PageResult<InspectionPlanDeviceDO> selectAppPage(InspectionPlanDevicePageReqVO reqVO){
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDeviceDO>()
                .eqIfPresent(InspectionPlanDeviceDO::getPlanId, reqVO.getPlanId())
                .inIfPresent(InspectionPlanDeviceDO::getDeviceId,reqVO.getDeviceIdList())
                .betweenIfPresent(InspectionPlanDeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionPlanDeviceDO::getId));
    }
}
